package cn.wolfcode.trip.base.service.impl;

import java.util.List;
import java.util.Map;

import cn.wolfcode.trip.base.mapper.ProductMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements IProductService {
	@Autowired
	private ProductMapper productMapper;

	@Override
	public PageInfo query(QueryObject qo) {
		PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
		List<Map> list = productMapper.queryForList(qo);
		return new PageInfo(list);
	}

    @Override
    public void updateStoreNum(Long productId, Long storeNum) {
        productMapper.updateStoreNum(productId,storeNum);
    }

	@Override
	public Long getStoreNum(Long productId) {
		return productMapper.selectStoreNum(productId);
	}

}
